package poj3295;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main
{
	private static BufferedInputStream in = new BufferedInputStream(System.in);
	private static int MAXINT = Integer.MAX_VALUE / 2;
	
	public static void main(String[] args) throws IOException
	{
		for(int i=readInt(); i>0; i--)
		{
			int n = readInt();
			int m = readInt();
			int w = readInt();
			
			Set<Edge> edges = new HashSet<Edge>();
			int[] distance = new int[n+1];
			
			Arrays.fill(distance, MAXINT);
			distance[1] = 0;
			
			for(int j=0; j<m; j++)
			{
				edges.add(new Edge(readInt(), readInt(), readInt()));
			}
			
			for(int j=0; j<w; j++)
			{
				edges.add(new Edge(readInt(), readInt(), -readInt()));
			}
			
			while(true)
			{
				boolean change = false;
				
				for(Edge edge : edges)
				{
					if(distance[edge.to] > distance[edge.from] + edge.power)
					{
						distance[edge.to] = distance[edge.from] + edge.power;
						change = true;
						
						if(distance[edge.to] < -10000)
						{
							change = false;
							break;
						}
					}
				}
				
				if(!change)
				{
					break;
				}
			}
			
			if(distance[1] < 0)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}

	private static int readInt() throws IOException
	{
		int i,sum=0;
		
		while(((i=in.read())&48) != 48 || i>57);
		
		for(;(i&56) == 48 || (i&62) == 56; i=in.read())
			sum = sum*10 + (i&15);
		
		return sum;
	}
	
	private static class Edge
	{
		int from;
		int to;
		int power;
		
		public Edge(int from, int to, int power)
		{
			this.from = from;
			this.to = to;
			this.power = power;
		}
	}
}
